package com.camel.studyApp.springboot;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

// 展示生命周期
@Component
public class LifeCycleBean {

    private static final Logger log = LoggerFactory.getLogger(LifeCycleBean.class);

    public LifeCycleBean() {
        log.warn("构造");
    }

    @Resource
    private void lifeCycleBean2(LifeCycleBean2 lifeCycleBean2) {
        log.warn("@Resource 生效 ： " + lifeCycleBean2);
    }

    @Autowired
    private void autuwire(@Value("${JAVA_HOME}") String home) {
        log.warn("@Autowired 生效 ：依赖注入： {}", home);
    }

    @PostConstruct
    public void init() {
        log.warn("初始化");
    }

    @PreDestroy
    public void destroy() {
        log.warn("销毁");
    }
}
